﻿CREATE PROCEDURE [acms].[Site_GetByRootUrl]
	@RootUrl varchar(255)
AS
if exists(select null from [acms].[Site_View] where Root = @RootUrl) begin
	SELECT *
	FROM [acms].[Site_View]
	WHERE Root = @RootUrl
end
else begin
	select a.*
	FROM [acms].[Site_View] a inner join [acms].[SiteMappings] b on a.Id = b.SiteId
	where b.[MappingName] = @RootUrl
end
RETURN 0;